README for ""Genetic Imprints, Party Life Cycles and Organizational Mortality: An Application of State-Space Duration Models", by Bolleyer, Correa-Vila and Katz, to appear in the Journal of Politics. 


This "Readme" file:
      - first provides background information about the software and packages used in the
        analysis ("Software requirements"); 
      - then describes the different files included in the replication packages and how they
        relate to the results reported in the manuscript and Online Appendix ("Description 
        of the files"); 
      - and finally lists the variables included in the data file, providing the names and coding           
        for each variable ("Codebook")



### SOFTWARE REQUIREMENTS

Given the complexity of the models estsimated in the paper, the Markov chain Monte Carlo (MCMC) algorithms were coded in C++ and called from R through Rcpp (Eddelbuettel, 2013), and executed via the University of Exeter High Performance Computing (HPC) cluster (see Section A.3 of the accompanying Online Appendix). While all the models can be estimated using a laptop or desktop computer, the execution time is considerably (around 5 times) shorter using a HPC cluster. 

For the code to work properly, you have to install an SSH Client (such as Putty or smilar) to connect to an HPC cluster, 
as well as the following R packages: "Rcpp", "RcppArmadillo", "coda", "ggplot2", "grid", "gridExtra", "gtble", "plyr", "psych", "survival", and "VGAM". 


When using a HPC cluster, you should load the R (we used version 3.3.1-foss-2016b) and GSL (we used version 2.1-foss-2016b) modules.


### DESCRIPTION OF THE FILES

In the estimation of each of the models reported in the manuscript and accompanying Online Appendix, we use:

1) A batch (shell) script (extension: ".sh"; e.g. "Statespace.sh") that submits the relevant R script to the HPC cluster. 
   Exeter's HPC cluster uses Slurm to manage the cluster workload.

2) An R script (extension: ".R"; e.g., "Statespace.R") that loads the relevant dataset, prepares the data for estimation, 
   and calls Rcpp to run the MCMC algorithm.

3) A C++ code (extension: ".cpp�) that contains the relevant MCMC algorithm - which depends on the particular model - e.g., Statespace, 
   Cox, Log-normal, Quadratic, Linear - to be fitted (see details below).
   
Once the models are estimated, we post-process all the results in R (see the description of "Processing.R" below).


Hence, these replication materials include the following files:


1) Files required to estimate the models used to produce the empirical findings in the manuscript and the Online Appendix:

   1.1) "Statespace.sh", "Statespace.R", "Statespace.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate our state-space         
	competing risks model presented in the manuscript (Section 3.4, "Estimation Approach"; 
        see also section A.3 of the Online Appendix). 
        The results displayed in Tables 2 and 3 (first column) and Figures 1, 3 and 4 of the         
	manuscript, as well as those presented in Figure A.7 and Table A.4 (first column) of the            
	Online Appendix, are based on these estimates.

   1.2) "Cox.sh", "Cox.R", "Cox.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate the Cox
         proportional hazards competing risks model described in Section 4 ("Results") of the
         manuscript (see also Section A.3 of the Online Appendix).
        The results displayed in Table 3 (second column) and Figure 2 of the manuscript, as well as         
	those presented in Table A.3 (columns 1 and 2) of the Online Appendix, are based on these         
	estimates.

   1.3) "Lognormal.sh", "Lognormal.R", "Lognormal.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate	the Log-                    
	normal competing risks model described in Section 4 ("Results") of the manuscript 
        (see also Section A.3 of the Online Appendix).
        The results displayed in Table 3 (third column) and Figure 2 of the manuscript, as well as         
	those presented in Table A.3 (columns 3 and 4) of the Online Appendix, are based on these         
	estimates.

   1.4) "Quadratic.sh", "Quadratic.R", "Quadratic.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate	the competing risks         
	specification that models the coefficients of the formative features as quadratic functions         
	of parties� age, described in Section A.4 of the Online Appendix.
        The results displayed in Table A.4 (column 2) and Figures A.8 and A.11 of the Online         
	Appendix are based on these estimates.

   1.5) "Weibull.sh", "Weibull.R", "Weibull.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate	the competing risks         
	specification that models the coefficients of the formative features as natural logarithms          
	of parties� age (a discretized version of the Weibull model), described in Section A.4 of         
	the Online Appendix.
        The results displayed in Table A.4 (column 3) and Figures A.9 and A.12 of the Online         
	Appendix are based on these estimates.

   1.6) "Linear.sh", "Linear.R", "Linear.cpp": 
	The batch file, R script and MCMC algorithm (coded in .cpp) to estimate	the competing risks         
	specification that models the coefficients of the formative features as linear functions
        of parties� age, described in Section A.4 of the Online Appendix.
        The results displayed in Table A.4 (column 4) and Figures A.10 and A.13 of the Online         
	Appendix are based on these estimates.

2) "Processing.sh" and "Processing.R": 
    The batch file and main R script used to post-process the estimates from all the models and 
    to produce the posterior summaries and descriptive statistics reported in the tables and     
    figures included in the manuscript and the Online Appendix. 


3) "Dataset.csv": 
    The data set employed in the analyses.The names of the variables in this data file are included     
    in the "Codebook" section below, along with a definition of each variable and a description of     
    the variable coding.
    A more in-depth description of the variable coding and sources is provided in Section 
    A.2 of the Online Appendix.



### CODEBOOK  

country = the polity (democracy) each party operates in 


case_id = party id 


merged = indicator for parties that merged with another political organization 


dissolved = indicator for parties that dissolved


organisation = indicator for societally rooted parties, coded as 1 for parties 
               whose foundation was supported by members or affiliates of identifiable 
               promoter organizations, and 0 otherwise.


newfamfirst = indicator for ideologically novel parties


finance_party_qualify = indicator for state funding, coded as 1 if a party won enough votes 
                        or seats in the most recent electoral cycle to obtain state funding,
                        and 0 otherwise


election_year_dummy = indicator for years in which national elections were held

indPOL = anti-establishment vote, measured as the vote share obtained by anti-political-establishment parties at the most recent election


efNPP = party-system fragmentation, captured using the effective number of parliamentary 
        parties in each country at the time of the observation


elec_coalition = indicator for parties that were part of a pre-electoral coalition in the most recent electoral cycle

log.seats = natural logarithm of the fraction of seats in the national parliament held by each party in any given year


logseats.centered = variable obtained by hierarchically centering log.seats


government = indicator for parties holding ministerial posts in the national government 
             in any given year. 


reg_gov = indicator for parties holding ministerial posts at the regional level in a given year


EU_parl = indicator for parties holding seats in the European Parliament in a given year


year_exist = party age, measured as the length of parties� life from its organizational foundation up to the time of the observation, in years.


years.centered = variable obtained by hierarhically centering year_exist 

years.centered.squared = variable obtained by raising years.centered to the power of 2 


log.partyyears = natural logarithm of party age 


OriginNew = whether parties have roots in pre-existing political organizations or not, coded as 
            1 if a party emerged from either a split or a merger of pre-existing political                     
	    organizations, and 0 if it was built from scratch without the support of members of                 
	    existing parties. 


distinctiveness = measure of party distinctiveness, coded as 0 if, at each point in time, 			          
		  any other party that represented the same ideological family as the formation 
                  in question had gathered at least 1% of the vote in the previous national                           
		  parliamentary election, and 1 otherwise


post.election.year = indicator for the year after a national election was held


pre.election.year = indicator for the year before a national election was held


votes = electoral performance, measured by the share of the popular vote gathered by each party in 	
	the most recent national election.  


votes.centered = variable obtained by hierarchically centering votes 



AUTHOR'S CONTACT INFORMATION:			

Gabriel Katz, University of Exeter. 
Amory Building, Rennes Drive, Exeter, EX4 4QJ, UK
email: G.Katz@exeter.ac.uk.







